package com.cloudbroker.bcs.platform.ltb.middle.service.impl;

import com.alibaba.fastjson.JSON;
import com.cloudbroker.bcs.common.dao.base.DAOBase;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.admin.vo.BlackKeyWordForm;
import com.cloudbroker.bcs.platform.ltb.middle.dao.BlackWordDAO;
import com.cloudbroker.bcs.platform.ltb.middle.entity.BlackWord;
import com.cloudbroker.bcs.platform.ltb.middle.service.BlackWordService;
import com.cloudbroker.bcs.platform.ltb.middle.service.BlackuserService;
import com.cloudbroker.bcs.platform.ltb.middle.service.base.TenantServiceImplBase;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by lili19289 on 2016/8/18.
 */
@Service
public class BlackWordServiceImpl extends TenantServiceImplBase<BlackWord,String> implements BlackWordService {

    @Resource
    private BlackWordDAO blackWordDAO;

    @Override
    protected DAOBase getDAO() {
        return blackWordDAO;
    }


    public void deleteBlackWord(BlackWord word){
        blackWordDAO.delete(word);
    }


    public void editBlackWord(BlackWord word){
        blackWordDAO.update(word);
    }

    public List<BlackWord> queryBlackWords(BlackKeyWordForm form){
        List<BlackWord> words= blackWordDAO.queryBlackWords(form);
        return words;
    }

    public BlackWord  getByContent(BlackWord word){
        return blackWordDAO.queryByContent(word);
    }

    @Override
    public String getAllBlackWords(){
        List<String> words = blackWordDAO.queryWords();
        return JSON.toJSONString(words);
    }

    public List<BlackWord> fetchAllBlackWords(BlackKeyWordForm form){
        return blackWordDAO.fetchAllBlackWords(form);
    }
}
